<?php
namespace wow\model\dbcon;


use wow\model\auth as amodel;
/**
 * Auth connection lib.
 * @author peec
 *
 */
class AuthDB extends \gnomephp\doctrine\DoctrineConnection{
	/**
	 * Doctrine entity manager.
	 * Publically available.
	 * @var Doctrine\ORM\EntityManager
	 */
	static public $em = null;
	
	/**
	 * Do not load entity manager several times on single page.
	 * 
	 * @var boolean
	 */
	static private $loaded=false;	

	
	static public function load(){
		parent::load();
		if (!self::$loaded){
			self::$em = self::getNewEntityManager(\gnomephp\Configuration::get('authdatabase'));
			
			self::$loaded = true;
		}
		
	}
	
	/**
	 * @return Doctrine\ORM\EntityManager The entity manager of Doctrine.
	 */
	static public function getEM(){
		return self::$em;
	}
	
	
	static public function getAllRealms(){
		self::load();

		$query = self::$em->createNativeQuery("SELECT * FROM realmlist", new amodel\Realmlist());
		return $query->getArrayResult();
		
		
	}



}